<%@ page language="java" contentType="text/html; charset=US-ASCII"
    pageEncoding="US-ASCII"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<br>
<script>
	function showAdminUtilityPanel(panelId){
			$( "#adminPanels .panel" ).hide();
			$("#"+panelId).show();
		}
</script>
<div class="row">
	<div class="col-lg-2">
		<div class="list-group">
		  <a class="list-group-item active">
		  	 Admin Utils
		  </a>
		  <a href="#" onClick="showAdminUtilityPanel('adminPasswordUtilityPanel')" class="list-group-item">Password Utility</a>
		  <a href="#" onClick="showAdminUtilityPanel('testSSHConnectionUtilityPanel')" class="list-group-item">SSH Test Connection</a>
	</div>
	</div>
	<div class="col-lg-10" id="adminPanels">
		<div id="adminUtils-alert-container"></div>
		<div class="panel panel-primary " style="display: none" id="adminPasswordUtilityPanel">
			<div class="panel-heading ">
				<i class="fa fa-filter"></i> Password Utility
			</div>
			 <div class="panel-body">
			 	<p>Use this Utility to encode and decode the password where ever password is used.</p>
			 	<form class="form" role="form" >
			 		<div class="form-group">
			 			     <label for="passwordValue" >Password:</label>
			 				 <input id="passwordValue" type="text" class="form-control" placeholder="Password Value" />
			 		</div>
			 		<div class="form-group">
			 			     <label for="passwordEncryptedValue" >Encrypted Value:</label>
			 				 <p id="passwordEncryptedValue" class="form-control-static" ></p>
			 		</div>
			 		<div class="form-group">
			 			     <label for="passwordDecryptedValue" >Decrypted Value:</label>
			 				 <p id="passwordDecryptedValue" class="form-control-static" ></p>
			 		</div>
			 		<div class="form-group">
			 			<button type="button" id="passwordEncryptBtn" class="btn btn-primary">Encrypt</button>
			 			<button type="button" id="passwordDecrptBtn" class="btn btn-primary">Decrypt</button>
			 		</div>
			 	</form>
			 </div>
		</div>
		<div class="panel panel-primary " style="display: none" id="testSSHConnectionUtilityPanel">
			<div class="panel-heading ">
				<i class="fa fa-filter"></i> SSH Test Connection 
			</div>
			 <div class="panel-body">
			 	<p>Use this Utility Test the SSH Connnection.</p>
			 	<form class="form" role="form" >
			 		<div class="form-group">
			 			     <label for="sshHostname" >Hostname:</label>
			 				 <input id="sshHostname" type="text" class="form-control" placeholder="Hostname" />
			 		</div>
			 		<div class="form-group">
			 			     <label for="sshUsername" >Username:</label>
			 				 <input id="sshUsername" type="text" class="form-control" placeholder="User Name" />
			 		</div>
			 		<div class="form-group">
			 			     <label for="sshPassword" >Password:</label>
			 			     <input id="sshPassword" type="password" class="form-control" placeholder="Password" />
			 				
			 		</div>
			 		<div class="form-group">
			 			     <label for="sshPort" >Port:</label>
			 			     <input id="sshPort" type="text" class="form-control"  value="22" placeholder="Port" />
			 				
			 		</div>
			 		<div class="form-group">
			 			<button type="button" id="sshTestConnectionBtn" class="btn btn-primary">Test</button>
			 			
			 		</div>
			 	</form>
			 </div>
		</div>
	</div>
</div>

<script>
	$(document).ready(function() {
		$("#passwordDecrptBtn").click(function(){
			$("#passwordDecryptedValue").empty();
			$("#passwordEncryptedValue").empty();
			 if ( $("#passwordValue").val() !='') {
			 	
			 	var decryptedValue=uft.decryptPassword($("#passwordValue").val());
			 	if(decryptedValue != ""){
			 		$("#passwordDecryptedValue").text(decryptedValue);
			 	}
			 	
			 }else{	
			 	$("#adminUtils-alert-container").atf_warn_flyover("Input the password Value", "oops!")
			 	$("#passwordValue").focus()
			 }
			 
			
		})
		
		$("#sshTestConnectionBtn").click(function(){
			if ($("#sshHostname").val() !='' && $("#sshUsername").val() !='' && $("#sshPassword").val() != '' &&  $("#sshPort").val() != '') {
				uft.testSshConnection($("#sshHostname").val(),$("#sshUsername").val() , $("#sshPassword").val(),$("#sshPort").val(),"adminUtils-alert-container")
			}
		})
		$("#passwordEncryptBtn").click(function(){
			$("#passwordDecryptedValue").empty();
			$("#passwordEncryptedValue").empty();
			 if ( $("#passwordValue").val() !='') {
			 	
			 	var encryptedValue=uft.encrptyPassword($("#passwordValue").val());
			 	if(encryptedValue != ""){
			 		$("#passwordEncryptedValue").text(encryptedValue);
			 	}
			 	
			 }else{	
			 	$("#adminUtils-alert-container").atf_warn_flyover("Input the password Value", "oops!")
			 	$("#passwordValue").focus()
			 }
			 
			
		})
	});
</script>

